import Vue from 'vue'
import VueRouter from 'vue-router'
import MainMeun from './views/mainMeun';
import userMeun, { children } from './views/userMeun';
import pages from './views/pages';
Vue.use(VueRouter)
const routes = [{
	path: '/',
	name: 'Index',
	title: '首页',
	component: () => import('@/views/index'),
	redirect: 'home',
	children: [
		...MainMeun,
		{
			path: '/user',
			name: 'user',
			meta: {
				title: 'user'
			},
			component: () => import(/* webpackChunkName: "userMeun" */ '@/views/user/index'),
			redirect: 'user/center',
			children: [
				...userMeun,
				...children
			]
		},
		...pages
	],
},
{
	path: '/login',
	name: 'login',
	meta: {
		title: 'login'
	},
	component: () => import(/* webpackChunkName: "pages" */ '@/views/login/index'),
},]

const router = new VueRouter({
	routes,
	//对于所有路由导航，简单地让页面滚动到顶部。 返回 savedPosition，在按下 后退/前进 按钮时，就会像浏览器的原生表现那样：
	scrollBehavior(to, from, savedPosition) {
		if (savedPosition) {
			return savedPosition
		} else {
			return { x: 0, y: 0 }
		}
	}
})

export default router


